package com.code.wflow.config;

import com.code.wflow.filter.TokenFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ggh
 * @date 2022/11/11
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean tokenFilterRegistrationBean() {
        FilterRegistrationBean<TokenFilter> registration = new FilterRegistrationBean();
        registration.setFilter(new TokenFilter());
        registration.addUrlPatterns("/*");
        registration.setName("tokenFilter");
        //过滤器顺序
        registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
        return registration;
    }
}
